<?php


namespace app\appapi\controller;


use app\common\model\ArticleModel;
use cmf\controller\RestBaseController;

class ArticleController extends RestBaseController
{
    public function get_article_list($cid)
    {
        $data = ArticleModel::where('cate', $cid)->order('id desc')->paginate();
        $this->success('ok', $data);
    }

    public function get_article_cat_list()
    {
        $cate = ArticleModel::getCate();
        unset($cate[0]);
        $this->success('ok', $cate);
    }

    public function get_article_info($id)
    {
        $data = ArticleModel::find($id);
        $data['image']=cmf_get_image_url($data);
        $this->success('ok', $data);
    }

    public function read_article($id)
    {
        ArticleModel::where('id', $id)->setInc('read_num');
        $this->success('ok');
    }
}